﻿using Gaea.Oracle;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Xunit;

namespace Gaea.Test
{
    public class GaeaOracleStopWatchFacts
    {
        public class Test
        {

        }

        [Fact]
        public void otherTest()
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            for (int i = 0; i < 5000; i++)
            {
                
            }
            sw.Stop();
            long time = sw.ElapsedMilliseconds;
        }

        [Fact]
        public void RegisterTest()
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            for (int i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
            }
            sw.Stop();
            long time = sw.ElapsedMilliseconds;
        }

        [Fact]
        public void OracleConnectionTest()
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            for (int i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                using (var connection = gaeaOraclePower.CreateConnection())
                {

                    connection.Close();
                }
            }
            sw.Stop();
            long time = sw.ElapsedMilliseconds;
        }

        /// <summary>
        /// Sync GaeaBasicPower 单元测试
        /// </summary>
        //[Fact]
        //public void QueryTest()
        //{
        //    //GaeaOraclePower.Register();
        //    //var gaeaOraclePower = new BasicPowerClass();
        //    //string commandText = $"select * from user_union_card where name=:name";
        //    //string parameters = "张三";
        //    //CommandType commandType = CommandType.Text;
        //    //var countList = new BasicPowerClass().Query<string>(commandText, new { name = parameters }, commandType);
        //    //Assert.Equal(18, countList.Count());
        //    Stopwatch sw = new Stopwatch();
        //    sw.Start();
        //    for (int i = 0; i < 5000; i++)
        //    {
        //        GaeaOraclePower.Register();
        //        var asyncBasicPowerClass = new TestAsyncOraclePower();
        //        usergroup up = new usergroup();
        //        up.GroupId = 44;
        //        up.UserId = "asdg";
        //        up.Id = asyncBasicPowerClass.Insert(up);


        //        string commandText = $"select * from usergroup where id=:id";
        //        int parameters = up.Id;
        //        CommandType commandType = CommandType.Text;
        //        var TaskcountList = asyncBasicPowerClass.Query<usergroup>(commandText, new { id = parameters }, commandType);
        //    }
        //    sw.Stop();
        //    long time = sw.ElapsedMilliseconds;
        //}

        //[Fact]
        //public void QuerySingleTest()
        //{

        //    GaeaOraclePower.Register();
        //    var stopwatch = new Stopwatch();
        //    string phonenumber = string.Empty;
        //    stopwatch.Start();
        //    for (var i = 0; i < 5000; i++)
        //    {
        //        var gaeaOraclePower = new TestOraclePower();
        //        string commandText = $"select phonenumber from user_union_card where name=:name";
        //        string parameters = "张彦";
        //        CommandType commandType = CommandType.Text;
        //        phonenumber = new TestOraclePower().QuerySingle<string>(commandText, new { name = parameters }, commandType);
        //    }
        //    stopwatch.Stop();
        //    long time = stopwatch.ElapsedMilliseconds;
        //}

        //[Fact]
        //public void DbQuerySingleTest()
        //{
        //    var stopwatch = new Stopwatch();
        //    stopwatch.Start();
        //    for (var i = 0; i < 5000; i++)
        //    {
        //        GaeaOraclePower.Register();    
        //        IDbConnection dbConnection = new TestOraclePower().CreateConnection();
        //        string commandText = $"select phonenumber from user_union_card where name=:name";
        //        string parameters = "张彦";
        //        CommandType commandType = CommandType.Text;
        //        var phonenumber = new TestOraclePower().QuerySingle<string>(dbConnection, commandText, new { name = parameters }, commandType);
        //    }
        //    stopwatch.Stop();
        //    long time = stopwatch.ElapsedMilliseconds;
        //}

        [Fact]
        public void ExecuteScalarTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"select phonenumber from user_union_card where name=:name";
                string parameters = "张彦";
                CommandType commandType = CommandType.Text;
                var phonenumber = new TestOraclePower().ExecuteScalar<string>(commandText, new { name = parameters }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbExecuteScalarTest()
        {
             var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                string commandText = $"select phonenumber from user_union_card where name=:name";
                string parameters = "张彦";
                CommandType commandType = CommandType.Text;
                var phonenumber = new TestOraclePower().ExecuteScalar<string>(dbConnection, commandText, new { name = parameters }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExecuteTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                string commandText = $"update user_union_card set phonenumber=:phonenumber where iduser=2841";
                string parameters = "18100000001";
                CommandType commandType = CommandType.Text;
                var row = new TestOraclePower().Execute(commandText, new { phonenumber = parameters }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbExecuteTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                string commandText = $"update user_union_card set phonenumber=:phonenumber where iduser=2841";
                string parameters = "18100000001";
                CommandType commandType = CommandType.Text;
                var row = new TestOraclePower().Execute(dbConnection, commandText, new { phonenumber = parameters }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindAllTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var list = new TestOraclePower().FindAll<user_>();
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindAll3Test()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var list = new TestOraclePower().FindAll<user_>(GaeaSort.ASC, "Id", 1000);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var list = new TestOraclePower().Find<user_>(commandText, new { id = parameters });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbFindTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var list = new TestOraclePower().Find<user_>(dbConnection, commandText, new { id = parameters });
                var guid = list.ToList()[0].guid;
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindOneTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var list = new TestOraclePower().FindOne<user_>(commandText, new { id = parameters });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds; 
        }

        [Fact]
        public void DbFindOne()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var UserInfo = new TestOraclePower().FindOne<user_>(dbConnection, commandText, new { id = parameters });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindByIdTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var UserInfo = new TestOraclePower().FindById<user_>(1);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbFindByIdTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                var UserInfo = new TestOraclePower().FindById<user_>(dbConnection, 1);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void InsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var ug = new usergroup();
                ug.UserId = "a1";
                ug.GroupId = 11;
                ug.IsDeleted = 1;
                new TestOraclePower().Insert(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbInsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                var ug = new usergroup();
                ug.UserId = "a2";
                ug.GroupId = 22;
                ug.IsDeleted = 1;
                new TestOraclePower().Insert(dbConnection, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void UpdateTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                var ug = new usergroup();
                ug.UserId = "a1";
                ug.GroupId = 1;
                ug.IsDeleted = 1;
                ug.Id = 38024;
                ug.GroupId = 34;
                basicPowerClass.Update(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void TInsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            usergroup usergroup = null;
            for (var i = 1; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var userGroupAdapter = new UserGroupAdapter();
                var id = userGroupAdapter.Insert(new usergroup()
                {
                    UserId = "a2",
                    GroupId = 2,
                    IsDeleted = 1
                });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbUpdateTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                IDbConnection dbConnection = basicPowerClass.CreateConnection();
                var ug = new usergroup();
                ug.UserId = "a2";
                ug.IsDeleted = 1;
                ug.Id = 38024;
                ug.GroupId = 33;
                basicPowerClass.Update(dbConnection, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void BatchInsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"Insert into usergroup(UserId,GroupId,IsDeleted) values(:UserId,:GroupId,:IsDeleted)";
                var ug = new usergroup();
                var ug1 = new usergroup();
                ug.UserId = "a3";
                ug.GroupId = 33;
                ug.IsDeleted = 1;
                ug1.UserId = "a4";
                ug1.GroupId = 44;
                ug1.IsDeleted = 1;
                var userList = new List<usergroup>();
                userList.Add(ug);
                userList.Add(ug1);
                int Users = new TestOraclePower().BatchInsert(commandText, userList);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbBatchInsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();
                string commandText = $"Insert into usergroup(UserId,GroupId,IsDeleted) values(:UserId,:GroupId,:IsDeleted)";
                var ug = new usergroup();
                var ug1 = new usergroup();
                ug.UserId = "a5";
                ug.GroupId = 55;
                ug.IsDeleted = 1;
                ug1.UserId = "a6";
                ug1.GroupId = 66;
                ug1.IsDeleted = 1;
                var userList = new List<usergroup>();
                userList.Add(ug);
                userList.Add(ug1);
                int Users = new TestOraclePower().BatchInsert(dbConnection, commandText, userList);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void BatchUpdateTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();

                var ug = new usergroup();
                var ug1 = new usergroup();
                //ug.Id = 42;
                ug.UserId = "a3";
                ug.GroupId = 3;
                ug.IsDeleted = 1;
                //ug1.Id = 43;
                ug1.UserId = "a4";
                ug1.GroupId = 4;
                ug1.IsDeleted = 1;

                ug.Id = 41560;


                ug1.Id = 41561;

                string commandText = $"Update usergroup set UserId=:UserId,GroupId=:GroupId,IsDeleted=:IsDeleted where Id=:Id";

                var userList = new List<usergroup>();
                userList.Add(ug);
                userList.Add(ug1);
                int Users = new TestOraclePower().BatchUpdate(commandText, userList);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DeleteTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                var ug = new alipay_wap_pay_record();
                ug.OrderCode = "dasdas";
                ug.ReturnUrl = "2353";
                ug.ShowUrl = "123";
                ug.NotifyUrl = "23123";
                ug.Id = basicPowerClass.Insert(ug);
                var count = basicPowerClass.Delete(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbDeleteTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                IDbConnection dbConnection = basicPowerClass.CreateConnection();
                var ug = new usergroup();
                ug.UserId = "232";
                ug.GroupId = 444;
                ug.IsDeleted = 0;
                ug.Id = basicPowerClass.Insert(dbConnection, ug);
                var ug2 = basicPowerClass.FindOne<usergroup>($"select * from usergroup where Id=:Id", new { Id = ug.Id });
                var count = basicPowerClass.Delete(dbConnection, ug2);
                Assert.Equal(1, count);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DeleteAllTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                new TestOraclePower().DeleteAll<alipay_wap_pay_record>();
                var list = new TestOraclePower().FindAll<alipay_wap_pay_record>();
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ModifyTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                var ug = new usergroup();

                ug.UserId = "a5";
                ug.GroupId = 5;
                ug.IsDeleted = 1;
                ug.Id = basicPowerClass.Modify(ug);

                ug.GroupId = 8;

                basicPowerClass.Modify(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbModifyTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                IDbConnection dbConnection = new TestOraclePower().CreateConnection();

                var ug1 = new usergroup();
                ug1.UserId = "a7";
                ug1.GroupId = 7;
                ug1.IsDeleted = 1;
                var modifyid = basicPowerClass.Modify(dbConnection, ug1);
                ug1.Id = modifyid;
                ug1.GroupId = 7;
                basicPowerClass.Modify(dbConnection, ug1);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void GetConnectionAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                using (var connection = gaeaOraclePower.CreateConnectionAsync())
                {
                    connection.Result.Close();
                }
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        //[Fact]
        //public async Task QueryAsyncTest()
        //{
        //    var stopwatch = new Stopwatch();
        //    stopwatch.Start();
        //    for (var i = 0; i < 5000; i++)
        //    {
        //        GaeaOraclePower.Register();
        //        var asyncBasicPowerClass = new TestAsyncOraclePower();
        //        usergroup up = new usergroup();
        //        up.GroupId = 44;
        //        up.UserId = "asdg";
        //        up.Id = await asyncBasicPowerClass.InsertAsync(up);


        //        string commandText = $"select * from usergroup where id=:id";
        //        int parameters = up.Id;
        //        CommandType commandType = CommandType.Text;
        //        var TaskcountList = await asyncBasicPowerClass.QueryAsync<usergroup>(commandText, new { id = parameters }, commandType);
        //    }
        //    stopwatch.Stop();
        //    long time = stopwatch.ElapsedMilliseconds;
        //}

        //[Fact]
        //public void QuerySingleAsyncTest()
        //{
        //    var stopwatch = new Stopwatch();
        //    stopwatch.Start();
        //    for (var i = 0; i < 5000; i++)
        //    {
        //        GaeaOraclePower.Register();
        //        var gaeaOraclePower = new TestOraclePower();
        //        string commandText = $"select phonenumber from user_union_card where name=:name";
        //        string parameters = "张彦";
        //        CommandType commandType = CommandType.Text;
        //        var Taskphonenumber = new TestAsyncOraclePower().QuerySingleAsync<string>(commandText, new { name = parameters }, commandType);
        //    }
        //    stopwatch.Stop();
        //    long time = stopwatch.ElapsedMilliseconds;
        //}

        //[Fact]
        //public void DbQuerySingleAsyncTest()
        //{
        //    var stopwatch = new Stopwatch();
        //    stopwatch.Start();
        //    for (var i = 0; i < 5000; i++)
        //    {
        //        GaeaOraclePower.Register();
        //        var gaeaOraclePower = new TestOraclePower();
        //        var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
        //        string commandText = $"select phonenumber from user_union_card where name=:name";
        //        string parameters = "张彦";
        //        CommandType commandType = CommandType.Text;
        //        var Taskphonenumber = new TestAsyncOraclePower().QuerySingleAsync<string>(dbConnection.Result, commandText, new { name = parameters }, commandType);
        //    }
        //    stopwatch.Stop();
        //    long time = stopwatch.ElapsedMilliseconds;
        //}

        [Fact]
        public void ExecuteScalarAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"select phonenumber from user_union_card where name=:name";
                string parameters = "张彦";
                CommandType commandType = CommandType.Text;
                var Taskphonenumber = new TestAsyncOraclePower().ExecuteScalarAsync<string>(commandText, new { name = parameters }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbExecuteScalarAsync()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                string commandText = $"select phonenumber from user_union_card where name=:name";
                string parameters = "张彦";
                CommandType commandType = CommandType.Text;
                var Taskphonenumber = new TestAsyncOraclePower().ExecuteScalarAsync<string>(dbConnection.Result, commandText, new { name = parameters }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExecuteAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                string commandText = $"update usergroup set userid=:userid where groupid=1000";
                string userid = "18100000002";
                CommandType commandType = CommandType.Text;
                var TaskRow = new TestAsyncOraclePower().ExecuteAsync(commandText, new { userid }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbExecuteAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                string commandText = $"update usergroup set userid=:userid where id=147";
                string userid = "18100000002";
                CommandType commandType = CommandType.Text;
                var TaskRow = new TestAsyncOraclePower().ExecuteAsync(dbConnection.Result, commandText, new { userid }, commandType);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindAllAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var TaskList = new TestAsyncOraclePower().FindAllAsync<user_>();
            }
            stopwatch.Stop();


            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var TaskList = new TestAsyncOraclePower().FindAsync<user_>(commandText, new { id = parameters });
            }
            stopwatch.Stop();
           long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbFindAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var TaskList = new TestAsyncOraclePower().FindAsync<user_>(dbConnection.Result, commandText, new { id = parameters });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void FindOneAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var TaskList = new TestAsyncOraclePower().FindAsync<user_>(commandText, new { id = parameters });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void DbFindOneAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                string commandText = $"select * from user_ where id=:id";
                int parameters = 1;
                var TaskList = new TestAsyncOraclePower().FindAsync<user_>(dbConnection.Result, commandText, new { id = parameters });
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task InsertAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var ug = new usergroup();
                ug.UserId = "a7";
                ug.GroupId = 77;
                ug.IsDeleted = 1;
                await new TestAsyncOraclePower().InsertAsync(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task DbInsertAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                var ug = new usergroup();
                ug.UserId = "a8";
                ug.GroupId = 88;
                ug.IsDeleted = 1;
                await new TestAsyncOraclePower().InsertAsync(dbConnection.Result, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task UpdateAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var ug = new usergroup();
                //ug.Id = 46;
                ug.UserId = "a7";
                ug.GroupId = 7;
                ug.IsDeleted = 1;
                ug.Id = await asyncBasicPowerClass.InsertAsync(ug);
                ug.GroupId = 199;

                await asyncBasicPowerClass.UpdateAsync(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task DbUpdateAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var ug = new usergroup();
                var dbConnection = await asyncBasicPowerClass.CreateConnectionAsync();
                //ug.Id = 47;
                ug.UserId = "a8";
                ug.GroupId = 8;
                ug.IsDeleted = 1;
                ug.Id = await asyncBasicPowerClass.InsertAsync(dbConnection, ug);

                ug.GroupId = 99;

                await asyncBasicPowerClass.UpdateAsync(dbConnection, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task BatchInsertAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                string commandText = $"Insert into usergroup(UserId,GroupId,IsDeleted) values(:UserId,:GroupId,:IsDeleted)";
                var ug = new usergroup();
                var ug1 = new usergroup();
                ug.UserId = "a9";
                ug.GroupId = 99;
                ug.IsDeleted = 1;
                ug1.UserId = "a10";
                ug1.GroupId = 1010;
                ug1.IsDeleted = 1;
                var userList = new List<usergroup>();
                userList.Add(ug);
                userList.Add(ug1);
                int Users = await new TestAsyncOraclePower().BatchInsertAsync(commandText, userList);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task DbBatchInsertAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                string commandText = $"Insert into usergroup(UserId,GroupId,IsDeleted) values(:UserId,:GroupId,:IsDeleted)";
                var ug = new usergroup();
                var ug1 = new usergroup();
                ug.UserId = "a11";
                ug.GroupId = 1111;
                ug.IsDeleted = 1;
                ug1.UserId = "a12";
                ug1.GroupId = 1212;
                ug1.IsDeleted = 1;
                var userList = new List<usergroup>();
                userList.Add(ug);
                userList.Add(ug1);
                int Users = await new TestAsyncOraclePower().BatchInsertAsync(dbConnection.Result, commandText, userList);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task BatchUpdateAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var ug = new usergroup();
                var ug1 = new usergroup();
                //ug.Id = 62;
                ug.UserId = "a11";
                ug.GroupId = 11;
                ug.IsDeleted = 1;
                ug.Id = await new TestAsyncOraclePower().InsertAsync(ug);

                //ug1.Id = 63;
                ug1.UserId = "a12";
                ug1.GroupId = 12;
                ug1.IsDeleted = 1;
                ug1.Id = await new TestAsyncOraclePower().InsertAsync(ug1);

                var userList = new List<usergroup>();
                userList.Add(ug);
                userList.Add(ug1);

                string commandText = $"Update usergroup set UserId=:UserId,GroupId=:GroupId,IsDeleted=:IsDeleted where Id=:Id";

                int Users = await new TestAsyncOraclePower().BatchUpdateAsync(commandText, userList);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task DeleteAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var ug = new alipay_wap_pay_record();
                ug.OrderCode = "dasdas";
                ug.ReturnUrl = "2353";
                ug.ShowUrl = "123";
                ug.NotifyUrl = "23123";
                ug.Id = await asyncBasicPowerClass.InsertAsync(ug);
                var count = await asyncBasicPowerClass.DeleteAsync(ug);
                Assert.Equal(1, count);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task DbDeleteAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var dbConnection = asyncBasicPowerClass.CreateConnectionAsync();
                var ug = new usergroup();
                ug.UserId = "232";
                ug.GroupId = 444;
                ug.IsDeleted = 0;
                ug.Id = await asyncBasicPowerClass.InsertAsync(dbConnection.Result, ug);
                var ug1 = await asyncBasicPowerClass.FindOneAsync<usergroup>($"select * from usergroup where Id=:Id", new { Id = ug.Id });
                var count = asyncBasicPowerClass.Delete(dbConnection.Result, ug1);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task DeleteAllAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                await new TestAsyncOraclePower().DeleteAllAsync<alipay_wap_pay_record>();
                var Tasklist = new TestAsyncOraclePower().FindAllAsync<alipay_wap_pay_record>();
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async Task ModifyAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var ug1 = new usergroup();
                ug1.UserId = "a13";
                ug1.GroupId = 13;
                ug1.IsDeleted = 1;
                var Taskmodifyid = await asyncBasicPowerClass.ModifyAsync(ug1);
                Assert.True(Taskmodifyid > 0);
                ug1.Id = Taskmodifyid;
                ug1.GroupId = 66;
                await asyncBasicPowerClass.ModifyAsync(ug1);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async void DbModifyAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var dbConnection = asyncBasicPowerClass.CreateConnectionAsync();

                var ug1 = new usergroup();
                //ug1.Id = 0;
                ug1.UserId = "a14";
                ug1.GroupId = 14;
                ug1.IsDeleted = 1;
                var Taskmodifyid = await asyncBasicPowerClass.ModifyAsync(dbConnection.Result, ug1);
                Assert.True(Taskmodifyid > 0);

                ug1.Id = Taskmodifyid;
                ug1.GroupId = 16;
                await asyncBasicPowerClass.ModifyAsync(dbConnection.Result, ug1);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void GetTableName()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var getTableNameByOracle = new GetTableNameByOracle();
                string tableName = getTableNameByOracle.GaeaName;
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExcludeTest()
        { var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var list = new TestOraclePower().FindAll<user_coin>();
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExcludeDbInsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                IDbConnection dbConnection = basicPowerClass.CreateConnection();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = basicPowerClass.Insert(dbConnection, ug);

            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExcludeInsertTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = new TestOraclePower().Insert(ug);
                var UserInfo = new TestOraclePower().FindById<user_coin>(ug.Id);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async Task ExcludeDbInsertAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var dbConnection = new TestAsyncOraclePower().CreateConnectionAsync();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = await new TestAsyncOraclePower().InsertAsync(dbConnection.Result, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async Task ExcludeInsertAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var gaeaOraclePower = new TestOraclePower();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = await new TestAsyncOraclePower().InsertAsync(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExcludeUpdateTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = basicPowerClass.Insert(ug);
                ug.coin = 6;
                ug.iduser = 6;
                basicPowerClass.Update(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExcludeDbUpdateTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                IDbConnection dbConnection = basicPowerClass.CreateConnection();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = basicPowerClass.Insert(dbConnection, ug);

                ug.coin = 6;
                ug.iduser = 6;
                basicPowerClass.Update(dbConnection, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task ExcludeUpdateAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = await asyncBasicPowerClass.InsertAsync(ug);

                ug.coin = 6;
                ug.iduser = 6;
                await asyncBasicPowerClass.UpdateAsync(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public async System.Threading.Tasks.Task ExcludeDbUpdateAsyncTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 1000; i++)
            {

                GaeaOraclePower.Register();
                var asyncBasicPowerClass = new TestAsyncOraclePower();
                var dbConnection = await asyncBasicPowerClass.CreateConnectionAsync();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = await asyncBasicPowerClass.InsertAsync(dbConnection, ug);

                ug.coin = 6;
                ug.iduser = 6;

                await asyncBasicPowerClass.UpdateAsync(dbConnection, ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }

        [Fact]
        public void ExcludeDeleteTest()
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                GaeaOraclePower.Register();
                var basicPowerClass = new TestOraclePower();
                var ug = new user_coin();
                ug.iduser = 5;
                ug.coin = 5;
                ug.Id = basicPowerClass.Insert(ug);
                var count = basicPowerClass.Delete(ug);
            }
            stopwatch.Stop();
            long time = stopwatch.ElapsedMilliseconds;
        }
    }
}
